package handlers

import (
	"github.com/gin-gonic/gin"
	"repo-adder/models"
)

func Add(c *gin.Context) {
	Type := c.PostForm("Type")
	Name := c.PostForm("Name")
	Address := c.PostForm("Address")
	if Type == "" || Name == "" || Address == "" {
		c.JSON(200, gin.H{
			"code": 0,
			"msg":  "仓库、仓库地址、仓库地址不能为空",
		})
		return
	}
	repo := models.Repo{
		Type:    Type,
		Name:    Name,
		Address: Address,
	}
	models.DB.Create(&repo)
	c.JSON(200, gin.H{
		"code": 200,
		"msg":  "添加成功",
	})
	return
}
